﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
	<class name="YiLe.Model.Domain.Role, YiLe.Model" table="Roles" lazy="true">
		<id name="RoleID" column="RoleID" type="int">
			<generator class="native"/>
		</id>
		<property name="RoleName" column="RoleName" type="string" length="50"/>
		<!-- 多对多关系：Role属于多个User-->
		<bag name="Users" table="Users_Roles" lazy="false">
			<key column="RoleID"/>
			<many-to-many column="UserID" class="YiLe.Model.Domain.User, YiLe.Model" />
		</bag>
		<!-- 一对多关系：Role有多个Permission lazy="false" inverse="true" cascade="all" -->
		<bag name="Permissions" table="Roles_Permissions" lazy="false">
			<key column="RoleID" />
			<many-to-many column="PermissionID" class="YiLe.Model.Domain.Permission, YiLe.Model"/>
		</bag>
	</class>
</hibernate-mapping>